﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Tsanie.DmPoster {
    public partial class InputForm : Form {
        public string Result { get; set; }

        private InputForm() {
            InitializeComponent();
            Result = null;
        }

        public static string ShowInput(Form owner, string prompt, string title) {
            return ShowInput(owner, prompt, title, null, 20, 20);
        }
        public static string ShowInput(Form owner, string prompt, string title,
            string defaultValue) {
            return ShowInput(owner, prompt, title, defaultValue, 20, 20);
        }
        public static string ShowInput(Form owner, string prompt, string title,
            string defaultValue, int offsetX, int offsetY) {
            InputForm frm = new InputForm();
            frm.Left = owner.Left + offsetX;
            frm.Top = owner.Top + offsetY;
            frm.Text = title;
            frm.labelPrompt.Text = prompt;
            if (!string.IsNullOrEmpty(defaultValue))
                frm.textBox.Text = defaultValue;
            frm.ShowDialog(owner);
            return frm.Result;
        }

        private void buttonOK_Click(object sender, EventArgs e) {
            Result = textBox.Text;
            this.Close();
        }
        private void buttonCancel_Click(object sender, EventArgs e) {
            Result = null;
            this.Close();
        }

    }
}
